package io.github.aaron.commonadmin.plugin;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.*;
import java.util.List;

/**
 * @Author aaron01.fan
 * @Date 2025/9/1 18:31
 * @Description 增强用插件
 **/
public class BoosterGenPlugin extends PluginAdapter {

    private static final String REPOSITORY_FULLY_TYPE = "org.springframework.stereotype.Repository";
    private static final String REPOSITORY_ANNOTATION = "@Repository";

    @Override
    public boolean validate(List<String> warnings) {
        return true;
    }

    @Override
    public boolean clientGenerated(Interface interfaze, IntrospectedTable introspectedTable) {
        // 添加 @Repository 注解
        interfaze.addImportedType(new FullyQualifiedJavaType(REPOSITORY_FULLY_TYPE));
        interfaze.addAnnotation(REPOSITORY_ANNOTATION);
        return true;
    }

}
